package cn.iocoder.yudao.module.worker.api.clerk;

import cn.iocoder.yudao.module.worker.api.clerk.dto.ClerkRespDTO;
import cn.iocoder.yudao.module.worker.convert.clerk.ClerkConvert;
import cn.iocoder.yudao.module.worker.dal.dataobject.clerk.ClerkDO;
import cn.iocoder.yudao.module.worker.service.clerk.ClerkService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
@Validated
public class ClerkApiImpl implements ClerkApi {

    @Resource
    private ClerkService clerkService;

    @Override
    public ClerkRespDTO getClerkById(Long clerkId) {
        ClerkDO clerkDO = clerkService.getClerk(clerkId);
        return ClerkConvert.INSTANCE.convert(clerkDO);
    }

    @Override
    public List<ClerkRespDTO> getClerkList(Set<Long> ids) {
        List<ClerkDO> clerkDOList = clerkService.getClerkList(ids);
        return ClerkConvert.INSTANCE.convert(clerkDOList);
    }

    @Override
    public List<ClerkRespDTO> getClerkListByUserId(Long userId) {
        List<ClerkDO> clerkDOList = clerkService.getClerkListByUserId(userId);
        return ClerkConvert.INSTANCE.convert(clerkDOList);
    }

    @Override
    public ClerkRespDTO getClerkByOrder(Long userId, String sex) {
        ClerkDO clerkDO = clerkService.getClerkByOrder(userId, sex);
        return ClerkConvert.INSTANCE.convert(clerkDO);
    }

    @Override
    public void updateClerkLevel(Long clerkId, Integer sum, Integer weekSum) {
        clerkService.updateClerkLevel(clerkId, sum, weekSum);
    }

    @Override
    public List<ClerkRespDTO> getNewClerkList() {
        List<ClerkDO> clerkList = clerkService.getNewClerkList();
        return ClerkConvert.INSTANCE.convert(clerkList);
    }
}
